home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / netpq.zip / NETPQ.C < prev    next >
Text File  |  1992-02-24  |  4KB  |  195 lines

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <dos.h>
  4.  
  5. #include "nos.h"
  6. #include "noslib.h"
  7. #include "netpq.h"
  8.  
  9. //
  10. //  NETPQ.EXE
  11. //
  12. //  Displays printer queue activity on all logged on servers.  The display
  13. //    updates every two seconds.  Queued files may be cancelled, held, or
  14. //    released by the operator.  If the operator has queue privileges, the
  15. //    operator can change the downloading status of each printer port and
  16. //    may 'rush' queued files.
  17. //
  18. //  This program uses the Borland C versions of the nos library included in
  19. //  the file 'book.zip' on the Artisoft BBS (602-293-0065) and was compiled
  20. //  using Borland C++.
  21. //
  22. //  Written by Alan R. Roney
  23. //
  24. //  Released into the public domain by the author.  The author accepts no
  25. //  responsiblity for any problems associated with use of this program.
  26. //
  27. //  This software is not to be included in any "for profit" software packages.
  28. //
  29. //  You are welcome to modify the source code for this program.  Please
  30. //  forward a copy of your changes to the author.
  31. //
  32. //  Comments should be directed to the author at:
  33. //
  34. //        Internet:        aroney@tso.uc.edu
  35. //        Artisoft:        alan roney
  36. //        Compuserve:     76330,3711
  37. //
  38.  
  39.  
  40. struct serverdef *server;
  41. struct localqueuedef *localqueue;
  42.  
  43. int currentserver, adaptornum, numberoflogins, currentprinter, found;
  44. int queuejobcount, printjobcount;
  45. int maxlocalqueuecount, localqueuecount;
  46.  
  47. char    servername [D_NAMESZ + 2];
  48.  
  49. struct PS serverps;
  50. struct queue_entry serverqe;
  51. struct time_block servertime;
  52. struct user_account serveraccount;
  53.  
  54.  
  55. main ()
  56. {
  57. int keypressed, i;
  58.  
  59.     setup ();
  60.  
  61.     do
  62.     {
  63.     do
  64.         {
  65.         getserverinfo ();
  66.         clrscr ();
  67.         reportinfo ();
  68.         showmenu ();
  69.  
  70.         i = 0;
  71.         while (i++ < 2)
  72.         {
  73.         sleep (1);
  74.         if (kbhit () != 0)
  75.             break;
  76.         }
  77.         }while (kbhit () == 0);
  78.  
  79.     keypressed = getextch ();
  80.  
  81.     switch (keypressed)
  82.         {
  83.         case key_f1:
  84.         f1keypressed ();
  85.         break;
  86.  
  87.         case key_f2:
  88.         f2keypressed ();
  89.         break;
  90.         }
  91.     lowvideo ();
  92.  
  93.     }while ( (keypressed == key_f1) || (keypressed == key_f2) );
  94.  
  95.     lowvideo ();
  96.     textcolor (LIGHTGRAY);
  97.     clrscr ();
  98.  
  99.     free (server);
  100.     free (localqueue);
  101. }
  102.  
  103.  
  104. setup ()
  105. {
  106.     //    Check for presence of NetBios Version 4.0 or greater
  107.  
  108.     if (NOSPresence () == -1)
  109.     {
  110.     printf ("NETBIOS not installed\n");
  111.     exit (1);
  112.     }
  113.  
  114.     if (NOSGetVersion () < 1024)
  115.     {
  116.     printf ("Incorrect NETBIOS Version\n");
  117.     exit (1);
  118.     }
  119.  
  120.     //    Find out how many servers this node is logged into
  121.  
  122.     numberoflogins = 0;
  123.     servername [0] = servername [1] = '\\';
  124.  
  125.     while (NOSGetLogin (&numberoflogins, &servername [2], &adaptornum) != -1)
  126.     numberoflogins++;
  127.  
  128.     if (numberoflogins <= 0)
  129.     {
  130.     printf ("Not logged into to any servers\a\n");
  131.     exit (1);
  132.     }
  133.  
  134.     //    open structures for storing information
  135.  
  136.     if ( (server = (struct serverdef *) calloc (numberoflogins, sizeof (struct serverdef))) ==    (struct serverdef *) 0)
  137.     {
  138.     printf ("Couldn't allocate space for server information\n");
  139.     exit (1);
  140.     }
  141.  
  142.     maxlocalqueuecount = 0;
  143.     if ( (localqueue = (struct localqueuedef *) calloc (1, sizeof (struct localqueuedef))) ==  (struct localqueuedef *) 0)
  144.     {
  145.     printf ("Couldn't allocate space for queue information\n");
  146.     exit (1);
  147.     }
  148.  
  149.     //    Get server names and queue privileges
  150.  
  151.     currentserver = 0;
  152.  
  153.     while (currentserver < numberoflogins)
  154.     {
  155.     if (NOSGetLogin (¤tserver, &servername [2], &adaptornum) == -1)
  156.         NOSperror ("NOSGetLogin");
  157.  
  158.     strcpy (server [currentserver] .servername, servername);
  159.  
  160.     //  Check for queue privileges
  161.  
  162.     if (NOSGetAccount (&serveraccount, servername) == -1)
  163.         NOSperror ("NOSGetAccount");
  164.     else
  165.         {
  166.         if (((serveraccount .UA_privilege & UA_privilege_superACL) != 0) ||
  167.         ((serveraccount .UA_privilege & UA_privilege_superqueue) != 0))
  168.         {
  169.         server [currentserver] .queue_privilege = true;
  170.         }
  171.         else
  172.         server [currentserver] .queue_privilege = false;
  173.         }
  174.     currentserver++;
  175.     }
  176. }
  177.  
  178.  
  179. showmenu ()
  180. {
  181.     textcolor (LIGHTGRAY);
  182.     highvideo ();
  183.     cprintf ("F1: ");
  184.     lowvideo ();
  185.     cprintf ("Control Port  ");
  186.     highvideo ();
  187.     cprintf ("F2: ");
  188.     lowvideo ();
  189.     cprintf ("Control Queue  ");
  190.     highvideo ();
  191.     cprintf ("Any other key: ");
  192.     lowvideo ();
  193.     cprintf ("Exit");
  194. }
  195.